<%


Function getRndNumber(intA,intB)
	Randomize   '初始化随机数生成器
	getRndNumber = Int((intB * Rnd) + intA)
End Function


Function SafeRequest(ParaValue)
	if instr(ParaValue," ") or instr(ParaValue,"%20") then 
	SafeRequest=False
	else
	SafeRequest=True
	end if
End function


'对应匹配通用函数
Function LogicM(str,A,B,l)
	Dim ii
	A=split(A,l)
	B=split(B,l)
	if Isnull(str) then exit function
	if Ubound(A)<>Ubound(B) then exit function
	for ii=0 to UBound(A)
		if Cstr(str)=Cstr(A(ii)) then
			LogicM=B(ii)
			exit Function
		end if
	next
	LogicM=False
End Function

function formselect(f,v,t,s)
	if Isnull(s) then s=""
	sql="select * from "&f&" Order by id"
	rs3.open sql,conn,1,1
	dim pcode
	pcode="<select name='"&t&"'>"

		if rs3.bof or rs3.eof then
			response.write "<option value=''>none</option>"
		else
			for i = 1 to rs3.recordcount
				if Cstr(rs3("id"))=Cstr(s) then
					pcode=pcode & "<option value='"&rs3(v)&"' selected>"&rs3(t)&"</option>"
				else
					pcode=pcode & "<option value='"&rs3(v)&"' >"&rs3(t)&"</option>"
				end if
			rs3.movenext
			next
		end if
	pcode=pcode & "</select>"
	formselect=pcode
	rs3.close
end function

function skillselect(n,s)
	dim text
	text="<select name='"&n&"'>"
	text=text & "<option value='未知' >未知</option>"
	for r = 0 to Ubound(ArrTradeTF)
		if getFormatTradeName(s)=ArrTradeTF(r)(langcode) then
			text=text & "<option value='"&ArrTradeTF(r)(0)&"' selected>"&ArrTradeTF(r)(langcode)&"</option>"
		else
			text=text & "<option value='"&ArrTradeTF(r)(0)&"' >"&ArrTradeTF(r)(langcode)&"</option>"
		end if
	next
	text=text & "</select>"
	skillselect=text
end function

function proselect(n,s)
	dim text
	text="<select name='"&n&"'>"
	for ig = 0 to Ubound(ArrTF)
		if getFormatProfessionName(s)=ArrTF(ig)(langcode) then
			text=text & "<option value='"&ArrTF(ig)(0)&"' selected>"&ArrTF(ig)(langcode)&"</option>"
		else
			text=text & "<option value='"&ArrTF(ig)(0)&"' >"&ArrTF(ig)(langcode)&"</option>"
		end if
	next
	text=text & "</select>"
	proselect=text
end function

function tribeselect(n,s)
	dim text
	text="<select name='"&n&"'>"
	text=text & "<option value='未知' >未知</option>"
	for ig = 0 to Ubound(ArrRaceTF)
		if getFormatRaceName(s)=ArrRaceTF(ig)(langcode) then
			text=text & "<option value='"&ArrRaceTF(ig)(0)&"' selected>"&ArrRaceTF(ig)(langcode)&"</option>"
		else
			text=text & "<option value='"&ArrRaceTF(ig)(0)&"' >"&ArrRaceTF(ig)(langcode)&"</option>"
		end if
	next
	text=text & "</select>"
	tribeselect=text
end function

function honorselect(n,s,t)
	dim text,sarr
	if instr(t,"A") or instr(t,"联")  then
		sarr=Array("无","列兵","下士","中士","军士长","士官长","骑士","骑士中尉","骑士队长","护卫骑士","少校","司令","统帅","元帅","大元帅")
	else
		sarr=Array("无","侦察兵","步兵","中士","高阶军士","一等军士长","石头守卫","血卫士","军团士兵","百夫长","勇士","中将","将军","督军","高阶督军")
	end if
	text="<select name='"&n&"'>"
	for ii = 0 to Ubound(sarr)
		if s=sarr(ii) then
			text=text & "<option value='"&sarr(ii)&"' selected>"&sarr(ii)&"</option>"
		else
			text=text & "<option value='"&sarr(ii)&"' >"&sarr(ii)&"</option>"
		end if
	next
	text=text & "</select>"
	honorselect=text
end function

 
function eventselect(n,s)
	dim text,sarr
	sarr=Array("装备掉落","拓荒成功","推倒BOSS","发现BOSS")
	text="<select name='"&n&"'>"
	for ig = 0 to Ubound(sarr)
		if s=sarr(ig) then
			text=text & "<option value='"&sarr(ig)&"' selected>"&sarr(ig)&"</option>"
		else
			text=text & "<option value='"&sarr(ig)&"' >"&sarr(ig)&"</option>"
		end if
	next
	text=text & "</select>"
	eventselect=text
end function

function playerstatusselect(n,s)
	dim text,sarr
	sarr=Array("正常","已退会","暂离","待审查","黑名单")
	text="<select name='"&n&"'>"
	for ig = 0 to Ubound(sarr)
		if s=sarr(ig) then
			text=text & "<option value='"&sarr(ig)&"' selected>"&sarr(ig)&"</option>"
		else
			text=text & "<option value='"&sarr(ig)&"' >"&sarr(ig)&"</option>"
		end if
	next
	text=text & "</select>"
	playerstatusselect=text
end function

function adminlevelselect(n,s)
	dim text,sarr
	sarr=Array("站点管理员","活动记分员","")
	sarr=Array("0","2","4","3","4")
	text="<select name='"&n&"'>"
	for ig = 0 to Ubound(sarr)
		if s=sarr(ig) then
			text=text & "<option value='"&sarr(ig)&"' selected>"&sarr(ig)&"</option>"
		else
			text=text & "<option value='"&sarr(ig)&"' >"&sarr(ig)&"</option>"
		end if
	next
	text=text & "</select>"
	playerstatusselect=text
end function

function dkpview(t)
	if t>0 then
		dkpview="<span class='green'>"&t&"<span>"
	elseif t<0 then
		dkpview="<span class='red'>"&t&"<span>"		
	else
		dkpview="0"
	end if
end function


Function eventclass(c)
	dim textc,arrc
	arrc = Array("加入","离开","拾取","分解","仓库","击杀","职务任命","团队事件","个人事件","活动事件")
	textc="<select name='event_class' onchange='javascript:eventselectclass()'>"
	textc=textc+ "<option value=' '>请选择</option>"
	for i = 0 to UBound(arrc)
		if c = arrc(i) then
			textc=textc+ "<option value='"&arrc(i)&"' selected>"&arrc(i)&"</option>"
		else
			textc=textc+ "<option value='"&arrc(i)&"'>"&arrc(i)&"</option>"
		end if
	next
	textc=textc+ "</select>"
	eventclass=textc
End Function

Function speceventclass(c)
	dim textc,arrc	
	arrc = Array("马甲替身","仓库购买","纪律奖惩","DKP转让","其它")
	textc="<select name='event_class' onchange='javascript:eventselectclass()'>"
	textc=textc+ "<option value=' '>请选择</option>"
	for i = 0 to UBound(arrc)
		if c = arrc(i) then
			textc=textc+ "<option value='"&arrc(i)&"' selected>"&arrc(i)&"</option>"
		else
			textc=textc+ "<option value='"&arrc(i)&"'>"&arrc(i)&"</option>"
		end if
	next
	textc=textc+ "</select>"
	speceventclass=textc
End Function


Function raidmemberselect(raidid,c)
	if Not IsNumeric(raidid) then Exit Function
	dim textc , idlist , namelist
	sql="select * from raid where id="&raidid
	rs3.open sql,conn,1,1
		if not (rs3.bof or rs3.eof) then
			idlist=split(rs3("raid_player"),", ")
		else
			Exit Function
		end if
	rs3.close

	sql="select * from player"
	rs3.open sql,conn,1,1
		if not (rs3.bof or rs3.eof) then
			for ig = 0 to UBound(idlist)
				rs3.movefirst
				namelist=namelist & ","
				for iii = 1 to rs3.recordcount
					if int(idlist(ig))=rs3("id") then 
						namelist=namelist & rs3("player_name")
					end if
					rs3.movenext
				next
			next
			namelist=Mid(namelist,2)
			namelist=split(namelist,",")
		else
			Exit Function
		end if
	rs3.close

		textc = "<select class='unuse' name='object'>"
			for ig = 0 to UBound(idlist)
				if c=idlist(ig) then
					textc = textc + "<option value='"&idlist(ig)&"' selected>"&namelist(ig)&"</option>"	
				else
					textc = textc + "<option value='"&idlist(ig)&"'>"&namelist(ig)&"</option>"	
				end if
			Next
		textc = textc + "</select>"
	raidmemberselect=textc
End Function 


Function selecteventdate(d,c)
	if not Isdate(d) then exit function
	dim sy,sm,sd,textc
	sy=year(d)
	sm=month(d)
	sd=day(d)
	textc="<select name='event_date'>"
	for ig=1 to 3
			textc=textc & "<option value='"&DateAdd("d",ig-1,sy&"-"&sm&"-"&sd)&"'>"&DateAdd("d",ig-1,sy&"-"&sm&"-"&sd)&"</option>"
	next
	textc=textc & "</select>"
	selecteventdate=textc
End function

Function name2ids(name)
		if not Instr(name," ")>0 then
			sql="select * from player where player_name='"&name&"'"
			rs3.open sql,conn,1,1
				if not(rs3.eof or rs3.bof) then
				name2ids=rs3("id")
				else
				name2ids=9999
				end if
			rs3.close
		end if
End Function

Function name2id(name)
	Dim ArrNames
	ArrNames=split(name,"|")
	for im = 0 to Ubound(ArrNames)
		if not Instr(ArrNames(im)," ")>0 then
			sql="select * from player where player_name='"&ArrNames(im)&"'"
			rs3.open sql,conn,1,1
				if not(rs3.eof or rs3.bof) then
				name2id=name2id&"<a href='player_detail.asp?id="&rs3("id")&"'>"&ArrNames(im)&"</a>|"
				else
				name2id=name2id&ArrNames(im)& "|"
				end if
			rs3.close
		end if
	next
	name2id=left(name2id,len(name2id)-1)
End Function

Function id2name(id)
	if not IsNumeric(id) or id="" then exit function
	sql="select * from player where id="&id
	rs3.open sql,conn,1,1
		if not(rs3.eof or rs3.bof) then
		id2name="<a href='player_detail.asp?id="&rs3("id")&"'>"&rs3("player_name")&"</a>"
		else
		id2name=id
		end if
	rs3.close
End Function

Function id2name2(id)
	if not IsNumeric(id) then exit function
	sql="select * from player where id="&id
	rs3.open sql,conn,1,1
		if not(rs3.eof or rs3.bof) then
		id2name2=rs3("player_name")
		else
		id2name2=id
		end if
	rs3.close
End Function


Sub OutDKP(jt,et,id,raid_actiontime,raid_time)
	dim temptime
	Response.write "<tr><td>111</td></tr>"
	sql="select * from raid_event where event_raidid="&id&" and (event_class='拾取' or event_class='仓库')"
	rs3.open sql,conn,1,1
		if not (rs3.bof or rs3.eof) then
			for iz = 1 to rs3.recordcount
				temptime=DateDiff("n",raid_actiontime,rs3("event_time"))/raid_time*100
	Response.write "<tr><td>:"&int(temptime)&":</td></tr>"
				if temptime < jt or temptime > et then
					aDKPd=aDKPd+rs3("event_dkp")/40
				end if
			rs3.movenext
			next
		else
	Response.write "<tr><td>000</td></tr>"
		end if
	rs3.close
End Sub

Function linec(i)
	if int(i/2)=i/2 then
		linec="b"
	else
		linec="a"
	end if
End function

Function time_type(tvar,tt)
  dim ttt:ttt=tvar
  if not(isdate(ttt)) then time_type="":exit function
  select case tt
  case 1	'10-10
    time_type=month(ttt)&"-"&day(ttt)
  case 11	'月-日
    time_type=month(ttt)&"月"&day(ttt)&"日"
  case 2	'年(2)-月-日 00-10-10
    time_type=right(year(ttt),2)&"-"&month(ttt)&"-"&day(ttt)
  case 3	'2000-10-10
    time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)
  case 33	'年(4)-月-日
    time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日"
  case 4	'23:45
    time_type=hour(ttt)&":"&minute(ttt)
  case 44	'时:分
    time_type=hour(ttt)&"时"&minute(ttt)&"分"
  case 5	'23:45:36
    time_type=hour(ttt)&":"&minute(ttt)&":"&second(ttt)
  case 55	'时:分:秒
    time_type=hour(ttt)&"时"&minute(ttt)&"分"&second(ttt)&"秒"
  case 6	'10-10 23:45
    time_type=month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
  case 66	'月-日 时:分
    time_type=month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&":"&minute(ttt)
  case 666	'月-日 时:分
    time_type=month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"
  case 7	'年(2)-月-日 时:分  00-10-10 23:45
    time_type=right(year(ttt),2)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
  case 8	'2000-10-10 23:45
    time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
  case 88	'年(4)-月-日 时:分
    time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"
  case 9	'2000-10-10 23:45:45
    time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)&":"&second(ttt)
    time_type=formatdatetime(time_type)
  case 99	'年(4)-月-日 时:分:秒
    time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"&second(ttt)&"秒"
	case "aa"
	time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日"&WeekDayName(weekday(now()),True)
	Case 90
	time_type=year(ttt)&month(ttt)&day(ttt)&hour(ttt)&minute(ttt)&second(ttt)
  case else
    time_type=ttt
  end select
end function


sub userlogin()
if Session(USID)<>"" then
	Response.write Session(USID)&"<ul><li><a href=""AdminLogin.asp?Action=Logout"">退出登录</a></li></ul>"
else
	Response.Write "	<a name='loginviewbtn' href='Javascript:;'>管理员登录</a>" & vbCrlf
	Response.Write "				<div id=""UesrLogin"">" & vbCrlf
	Response.Write "					<form method=""post"" action=""AdminLogin.asp"">" & vbCrlf
	Response.Write "						<ul><li>账号 <input type=""text"" name='u_name' size=""15""/></li>" & vbCrlf
	Response.Write "						<li>密码 <input type=""password"" name='u_password' size=""15""/></li> <li><input type='submit' value='管理员登录' /></li></ul>" & vbCrlf
	Response.Write "					</form>" & vbCrlf
	Response.Write "				</div>" & vbCrlf
end if
end sub




'物品简单分类,
Function eqpic(item,tooltip)
	Dim Arrtooltip , tooltipText
	Select Case True
		Case instr(item,"头颅")>0 
			picfile="skull.jpg'"
		Case instr(item,"弓")>0 
			picfile="bow.jpg'"
		Case instr(item,"靴")>0 or instr(item,"鞋")>0
			picfile="boots.jpg'"
		Case instr(item,"匕首")>0 
			picfile="blade.jpg'"
		Case instr(item,"手套")>0 
			picfile="gauntlets.jpg'"
		Case instr(item,"腕")>0 
			picfile="bracer.jpg'"
		Case instr(item,"袍")>0 
			picfile="shirt.jpg'"
		Case instr(item,"肩")>0
			picfile="shoulder.jpg'"
		Case instr(item,"戒")>0 
			picfile="ring.jpg'"
		Case instr(item,"枪")>0 
			picfile="rifle.jpg'"
		Case instr(item,"头")>0 or instr(item,"角饰")>0
			picfile="helmet.jpg'"
		Case instr(item,"腰")>0 
			picfile="belt.jpg'"
		Case instr(item,"胸")>0 
			picfile="chesta.jpg'"
		Case instr(item,"暗影之击")>0 
			picfile="spear.jpg'"
		Case instr(item,"锤")>0 
			picfile="hammer.jpg'"
		Case instr(item,"魔典")>0 
			picfile="book.jpg'"
		Case instr(item,"封印")>0 or instr(item,"神圣之眼")>0 
			picfile="talisman.jpg'"
		Case instr(item,"腿")>0 or instr(item,"裤")>0
			picfile="pants.jpg'"
		Case instr(item,"纯焰精华")>0 
			picfile="potion.jpg'"
		Case instr(item,"盾")>0 or instr(item,"防御")>0 or instr(item,"壁")>0
			picfile="shield.jpg'"
		Case instr(item,"勋章")>0
			picfile="talisman.jpg'"
		Case instr(item,"护手")>0
			picfile="gauntlets.jpg'"
		Case instr(item,"护符")>0 or instr(item,"项圈")>0 
			picfile="necklace.jpg'"
		Case instr(item,"杖")>0
			picfile="staff.jpg'"
		Case instr(item,"斗篷")>0 or instr(item,"披")>0
			picfile="cape.jpg'"
		Case instr(item,"勋章")>0
			picfile="talisman.jpg'"
		Case instr(item,"勋章")>0
			picfile="talisman.jpg'"
		Case instr(item,"剑")>0 or instr(item,"刃")>0
			picfile="sword.jpg'"
		Case instr(item,"矿石")>0
			picfile="ore.jpg'"
		Case instr(item,"水晶")>0
			picfile="gem.jpg'"
		Case else
			picfile="unknow.jpg'"
	End Select

	if tooltip<>"" then
		ArrTooltip = Split(tooltip,";")
		for ig = 3 to Ubound(ArrTooltip)
			Select Case True
				Case Instr(ArrTooltip(ig),"|")>0
					tooltipText=tooltipText&"<p>"&Replace(ArrTooltip(ig),"|","<span>")&"</span></p>"
				Case Instr(ArrTooltip(ig),"装备：")>0 or Instr(ArrTooltip(ig),"使用：")>0
					tooltipText=tooltipText&"<p class=""effect"">"&ArrTooltip(ig)&"</p>"
				Case Instr(ArrTooltip(ig),"/")>0
					tooltipText=tooltipText&"<p class=""GoldText"">"&ArrTooltip(ig)&"</p>"
				Case Instr(ArrTooltip(ig),"套装：")>0
					tooltipText=tooltipText&"<p class=""GoldText"">"&ArrTooltip(ig)&"</p>"
				Case else
					tooltipText=tooltipText&"<p>"&ArrTooltip(ig)&"</p>"
			End Select
		next
		tooltipText="<h4 class="""&color2CSS(ArrTooltip(0))&""">"&ArrTooltip(2)&"</h4>"&tooltipText
		eqpic="<a href='http://db.ngacn.cc/main.php?func=170&spc=1111110&sc_kval="&server.urlencode(item)&"' target='_blank'><img src='"&LCase(IconPath&ArrTooltip(1)&IconExt)&"' class='eqpic' alt='"&tooltipText&"' /></a>"
	else
		tooltipText=item
		itemID=Split(item,"#")
		If UBound(itemID) = 1 then
			eqpic="<a href='http://cn.wowarmory.com/item-info.xml?i="&itemID(1)&"' target='_blank'><img name='item' src='images/icon/"&picfile&"' class='eqpic' itemID="""&itemID(1)&""" alt='"&itemID(0)&"' /></a>"
		Else
			eqpic="<a href='http://db.ngacn.cc/main.php?func=170&spc=1111110&sc_kval="&server.urlencode(item)&"' target='_blank'><img src='images/icon/"&picfile&"' class='eqpic' alt='"&tooltipText&"' /></a>"
		End If
	end if

End Function


Function delItemID(strItemName)
	If InStr(strItemName,"#") > 0 Then
		Dim strT
		strT = Split(strItemName,"#")
		delItemID = strT(0)
	Else
		delItemID = strItemName
	End If
End Function


Function color2CSS(color)
	Select Case color
		Case "ffffffff"
			color2CSS="standard"
		Case "ff1eff00"
			color2CSS="good"
		Case "ff0070dd"
			color2CSS="superior"
		Case "ffa335ee"
			color2CSS="epic"
		Case "ffa335ee"
			color2CSS="legendary"
	End Select
End Function

Function raidPic(name)
	Select Case True
		Case instr(name,"NX")>0 or instr(name,"Nax")>0 or instr(name,"NAXX")>0
			picfile="Naxx.gif'"
		Case instr(name,"BWL")>0 or instr(name,"黑翼")>0 or instr(name,"黑E")>0 
			picfile="bwl.gif'"
		Case instr(name,"ONX")>0 or instr(name,"MM")>0 or instr(name,"黑龙")>0 
			picfile="onx.gif'"
		Case instr(name,"ZG")>0 or instr(name,"大祖")>0 or instr(name,"Zug")>0 
			picfile="zg.gif'"
		Case instr(name,"AQ40")>0 or instr(name,"神庙")>0 or instr(name,"TAQ")>0 or instr(name,"TQL")>0 
			picfile="aq40.gif'"
		Case instr(name,"AQ20")>0 or instr(name,"废墟")>0 or instr(name,"AQL")>0 or instr(name,"RQL")>0 
			picfile="aq20.gif'"
		Case instr(name,"MC")>0 or instr(name,"10")>0 or instr(name,"9")>0 
			picfile="mc.gif'"
		 Case Else
			picfile="none.gif'"
	End Select
	raidpic="<img src='images/raid/"&picfile&"' class='eqpic' alt='"&name&"' />"
End Function

Function ProPic(name)
	Select Case True
		Case instr(name,"德")>0
			picfile="druid.png"
		Case instr(name,"战")>0
			picfile="warrior.png"
		Case instr(name,"圣")>0
			picfile="paladin.png"
		Case instr(name,"牧")>0
			picfile="priest.png"
		Case instr(name,"法")>0
			picfile="mage.png"
		Case instr(name,"贼")>0
			picfile="rogue.png"
		Case instr(name,"猎")>0
			picfile="hunter.png"
		Case instr(name,"术")>0
			picfile="warlock.png"
		Case instr(name,"萨")>0
			picfile="shaman.png"
		Case instr(name,"死")>0
			picfile="deathknight.png"
		Case Else
			picfile="female.gif"
	End Select
	ProPic="<img src='images/icon/"&picfile&"' class='eqpic' alt='"&name&"' />"
End Function

function BaseDKP(pid,cid)
	if IsNumeric(pid) then
	sql="select top 1 * from player_dkp where player_id="&pid&" and raid_class="&cid
	else
	sql="select top 1 * from player_dkp where player_name='"&pid&"' and raid_class="&cid
	end if
	rs2.open sql,conn,1,1
		if rs2.bof or rs2.eof then
			BaseDKP=0
		else
			BaseDKP=rs2("player_Basedkp")
		end if
	rs2.close
end function

'
function raidclassText(cid)
	if not IsNumeric(cid) or cid="" then exit function
	sql="select top 1 * from raid_class where id="&cid
	rs2.open sql,conn,1,1
		if rs2.bof or rs2.eof then
			raidclassText="<b>未设置分类</b>"
		else
			raidclassText=rs2("class_name")
		end if
	rs2.close
end function


function raidclassid(cname)
	if not SafeRequest(cname) then exit function
	sql="select top 1 * from raid_class where class_name='"&cname&"'"
	rs2.open sql,conn,1,1
		if rs2.bof or rs2.eof then
			raidclassid=False
		else
			raidclassid=rs2("id")
		end if
	rs2.close
end function

'=============================
'字符过滤函数
'=============================
function htmlencode2(str)
dim result
dim l
if isNULL(str) then 
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"&lt;"
case ">"
result=result+"&gt;"
case chr(13)
result=result+"<br />"
case chr(34)
result=result+"&quot;"
case "&"
result=result+"&amp;"
case chr(32)
'result=result+"&nbsp;"
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9)  then
result=result+"&nbsp;"
else
result=result+" "
end if
else
result=result+"&nbsp;"
end if
case chr(9)
result=result+""
case else
result=result+mid(str,i,1)
end select
next 
htmlencode2=result
end function


sub showerror(text)
	response.write "<div class='message'>"
	response.write "<h3>产生如下错误导致程序中断:</h3>"
	response.write "<div>"&text&"</div>"
	response.write "</div>"
end sub

sub showmessage(text)
	response.write "<div class='message'>"
	response.write "<h3>提示信息:</h3>"
	response.write "<div>"&text&"</div>"
	response.write "</div>"
end sub

function selectraid2()
	Dim stext
	stext=stext& "<form method='post' action=''><select name='filter' onChange='javascript:submit();'>"
	stext=stext& "<option value=''>过滤</option>"
	stext=stext& "<option value='all'>显示全部</option>"
	stext=stext& "<option value='edit'>未完成编辑的</option>"
	stext=stext& "<option value='end'>已归档的</option>"
	stext=stext& "<option value=''>===按DKP分类===</option>"
		sql="select * from raid_class order by id desc"
		rs.open sql,conn,1,1
		if not (rs.eof or rs.bof) then
			for i = 1 to rs.recordcount
			stext=stext& "<option value='D"&rs("id")&"'>"&rs("class_name")&"</option>"
			rs.movenext
			next
		end if
		rs.close
	stext=stext& "<option value=''>===按制度分类===</option>"
		sql="select * from ruler order by id desc"
		rs.open sql,conn,1,1
		if not (rs.eof or rs.bof) then
			for i = 1 to rs.recordcount
			stext=stext& "<option value='R"&rs("id")&"'>"&rs("ruler_name")&"</option>"
			rs.movenext
			next
		end if
		rs.close	
	stext=stext& "</select></form>"
	selectraid2=stext
end function


'=============================
'通用分页函数 V3.0
'记录集对象rec ;每页显示n条 ; 链接地址m(可带参数) ; 前后显示c个页码后省略
'记录指针移动标准算法: rs.move (request("page")-1)*n
'SULei 2005.1.10
'=============================
function pages(rec,n,m,c) 

	dim counts,k,max,s
	k="?"
	s=1
	counts=rec.recordcount
	if Instr(m,"?")>0 then k="&amp;" '没有参数用"?",否则就用"&"
	if (request("page")-c)>0 then '向后页码省略计算
		s=(request("page")-c)
		counts=counts-(s-1)*n
	end if
	for i=s to counts
		if int(Request("page"))=i then
			pages=pages &"<a href='"&m&k&"page="&i&"' class='CPage' >"&i&"</a> " '打标当前页
		else
			pages=pages &"<a href='"&m&k&"page="&i&"'>"&i&"</a> "
		end if
		counts=counts-n
		if counts<1 or i=request("page")+c then
			max=Abs(int((rec.recordcount/n)*-1))'记录最大页数
			exit for
		end if
	next
	if max=0 then max=1
	if int(request("page"))<1 then
	CP=1
	else
	CP=int(request("page"))
	end if
	if int(request("page"))<max and max>1 then pages=pages&" <a href='"&m&k&"page="&CP+1&"'>next</a>"
	if int(request("page"))>1 then pages="<a href='"&m&k&"page="&request("page")-1&"'>prev</a> "&pages
	if max=1 then pages="仅一页"
	pages=pages&" [共"&rec.recordcount&"条记录,当前第"&CP&"/"&max&"页,每页"&n&"条]"
end function


'根据参数格式化数值
Function cPre(Vint)
	if not IsNumeric(Vint) then 
		cPre="-"
		exit function
	end if
	if Precision="1" then
		cPre=FormatNumber(Vint,2)
	else
		cPre=CLng(Vint)
	end if
End Function


Function formattime(timed)
	If timed<60 Then
		formattime=timed&"分钟"
	Else
		formattime=int(timed/60)&"小时"&Int((timed/60-int(timed/60))*60)&"分钟"
	End if
End Function


Function office2img(strName)
	Dim ArrStr , ttext , ArrNum
	If strName<>"" Then
		ArrStr=Split(strName,"|")
		For iy = 0 To UBound(ArrStr)-1
		ArrNum=Split(ArrStr(iy),",")
		ttext=ttext& "<img src='images/icon/officer.gif' alt='+"&ArrNum(1)&"'>"&ArrNum(0)
		Next
	End If
	office2img=ttext
End Function


function lootview(t)
	if IsNull(t) or t="" then
	lootview="-"
	else
	t2=split(t,"|")
	for i = 1 to UBound(t2)
		t3=t3& "<li>[<a href='http://db.ngacn.cc/main.php?func=170&spc=1111110&sc_kval="&server.urlencode(t2(i))&"' target='_blank' onmouseover=""epicRead('ajax_reader.asp?key="&server.urlencode(t2(i))&"',this);"">"&t2(i)&"</a>]</li>"
	next
	lootview="<ol class='items'>"&t3&"</ol>"
	end if
	'
end Function

'按角色名查询
Sub Search()
	if SafeRequest(request("keyword")) And request("keyword")<>"" And Len(request("keyword"))<13  then
		sql = "select top 1 * from player where player_name='"&request("keyword")&"'"
		rs.open sql,conn,1,1
		If rs.eof Or rs.bof Then
			SearchError = request("keyword")&" 未找到"
		Else
			response.Redirect "player_detail.asp?id="&rs("id")
		End If
		rs.close
	end if
End Sub

'获得附加Ajax链接的拾取物品
function getLootItemsLink(t)
	if IsNull(t) or t="" then
	getLootItemsLink="-"
	else
	t2=split(t,"|")
	for i = UBound(t2) To 1 Step -1
		If UBound(t2)-i = MaxShowLootItems Then
			t3=t3&"... (共"&UBound(t2)&"件)"
			Exit for
		End If
		t3=t3& "<li>[<a href='http://db.ngacn.cc/main.php?func=170&spc=1111110&sc_kval="&server.urlencode(t2(i))&"' target='_blank' onmouseover=""epicRead('ajax_reader.asp?key="&server.urlencode(t2(i))&"',this);"">"&delItemID(t2(i))&"</a>]</li>"
	next
	getLootItemsLink="<ol class='items'>"&t3&"</ol>"
	end if
	'
end Function

'获得指定日期的活动计划
Function getDatePlans(strDate)
	Dim divRaids
	sql="select * from article where article_class='c' and article_date like '%"&DateValue(strDate)&"%' and article_text<>'' order by article_date"
	rs.open sql,conn,1,1
	If rs.bof Or rs.eof Then
		rs.close
		Exit Function
	Else
		For il = 1 To rs.recordcount
			divRaids=divRaids & "<div class='aevent'>"
			divRaids=divRaids & "<h4>计划:"&rs("article_text")&"</h4>"
			divRaids=divRaids & "</div>"
			rs.movenext
			if rs.eof then exit for
		next
	End If
	rs.close
	getDatePlans = divRaids
End Function

'获得指定日期的活动报告
Function getDateRaids(strDate)
	Dim divRaids
	sql="select top 10 * from raid where raid_actiontime like '%"&DateValue(strDate)&"%'"
	rs.open sql,conn,1,1
	If rs.bof Or rs.eof Then
		rs.close
		Exit Function
	Else
		For il = 1 To rs.recordcount
			divRaids=divRaids & "<div class='aevent'>"
			divRaids=divRaids & "<h4>活动:<a href='raid_report.asp?id="&rs("id")&"'>"&rs("raid_name")&"</a></h4>"
			divRaids=divRaids & "<span>"&rs("raid_plan")&"</span>"
			divRaids=divRaids & "</div>"
			rs.movenext
			if rs.eof then exit for
		next
	End If
	rs.close
	getDateRaids = divRaids
End Function


'获得指定日期的副本更新事件 TBC Only
Function getDateEvents(strDate)
	Dim Events
			if Weekday(strDate)=3 then '服务器维护日
				Events=Events& "<li>卡拉赞</li><li>毒蛇神殿</li><li>黑暗神殿</li><li>海加尔峰</li><li>风暴要塞</li><li>格鲁尔的巢穴</li><li>玛瑟里顿的巢穴</li><li>太阳井高地</li>"
			end if
			'if datediff("d",Basedate,strDate)/5=Cint(datediff("d",Basedate,strDate)/5) then '每隔5日
			'	Events=Events& "<li>奥妮克希亚</li>"
			'end if
			if datediff("d",dateadd("d",-2,Basedate),strDate)/3=Cint(datediff("d",dateadd("d",-2,Basedate),strDate)/3) then '每隔3日-1
				Events=Events& "<li>祖阿曼</li>"
			end If
		getDateEvents="<ul class='events'>"&Events&"</ul>"
End Function

'根据兼容表获得当前语言的职业名称
Function getFormatProfessionName(strPName)
	For i = 0 To UBound(ArrTF)
		For ik = 0 To UBound(ArrTF(i))
			If strPName=ArrTF(i)(ik) Then
				getFormatProfessionName=ArrTF(i)(langcode)
				Exit Function
			End If
		Next
	Next
	getFormatProfessionName="未知"
End Function

'根据兼容表获得商业技能名称
Function getFormatTradeName(strTradeName)
	For ix = 0 To UBound(ArrTradeTF)
		For ik = 0 To UBound(ArrTradeTF(ix))
			If strTradeName = ArrTradeTF(ix)(ik) Then
				getFormatTradeName = ArrTradeTF(ix)(langcode)
				Exit Function
			End If
		Next
	Next
	getFormatTradeName="未知"
End Function


'根据兼容表获得标准的简体中文种族名称
Function getFormatRaceName(strRaceName)
	For ir = 0 To UBound(ArrRaceTF)
		For ik = 0 To UBound(ArrRaceTF(ir))
			If strRaceName=ArrRaceTF(ir)(ik) Then
				getFormatRaceName=ArrRaceTF(ir)(langcode)
				Exit Function
			End If
		Next
	Next
	getFormatRaceName="未知"
End Function


'获得职业图标
Function getProfessionSmallIco(strPName)
	For iy = 0 To UBound(ArrTF)
		If strPName=ArrTF(iy)(0) Then
			getProfessionSmallIco="images/icon/"&ArrTF(iy)(Ubound(ArrTF(iy)))&".gif"
			Exit Function
		End If
	Next
	getProfessionSmallIco="images/icon/1.gif"
End Function

'获得种族图标
Function getRaceSmallIco(strPName)
	For i = 0 To UBound(ArrRaceTF)
		If strPName=ArrRaceTF(i)(0) Then
			getRaceSmallIco="images/icon/a"&ArrRaceTF(i)(Ubound(ArrRaceTF(i)))&".gif"
			Exit Function
		End If
	Next
	getRaceSmallIco="images/icon/a1.gif"
End Function


Function cov2Time(strTime)
	If Len(strTime)=17 Then
		cov2Time = getTimeMRT207(strTime)
	ElseIf IsNumeric(strTime) And Len(strTime)=10 Then
		cov2Time = getTimeRT150(strTime)
	ElseIf IsDate(strTime) Then
		cov2Time = strTime
	Else 
		cov2Time = False 
	End If
End Function

'转换CTRT的秒计时间为一般格式
function getTimeRT150(intSecond)
	If IsNumeric(intSecond) then
	getTimeRT150=DateAdd("s",intSecond,"1970-1-1")
	Else
	getTimeRT150=getTimeMRT207(intSecond)
	End If 
end Function


'转换时间为CTRT的秒计
function getRT150Time(ntime)
	If IsDate(ntime) then
	getRT150Time=DateDiff("s","1970-1-1",ntime)
	Else
	getRT150Time=DateDiff("s","1970-1-1",Now())
	End If 
end Function

'日期格式05/10/08 20:05:00 的正确转换
Function getTimeMRT207(strtime)
	dim arrD
	arrD=split(strtime,"/")
	if UBound(arrD)<2 then response.write "errorDateFormat"&d
	getTimeMRT207="20"&left(arrD(2),2)&"-"&arrD(0)&"-"&arrD(1)&" "&Mid(arrD(2),4)
End Function

'获得用于日历的星期几的文字
Function getWeekNameCN(wdate)
	Dim ArrWeekName
	ArrWeekName = Array("" ,"周日" ,"(一)" ,"(二)" ,"(三)" ,"(四)" ,"(五)" ,"(六)")
	getWeekNameCN= ArrWeekName(weekday(wdate))
End Function

'标准的英文BOSS名称转换成简体中文
Function getBossName(strName)
	For i = 0 To UBound(BossName)
		If Trim(strName) = BossName(i)(0) Then
			getBossName = BossName(i)(1)
			Exit For
		End If
	Next
End Function

'标准英文副本名转缩写
Function getInstanceAb(strName)
	getInstanceAb=Trim(strName)
	For ir = 0 To UBound(Instance)
		If Trim(strName) = Instance(ir)(0) Then
			getInstanceAb = Instance(ir)(2)
			Exit For
		End If
	Next
End Function

'标准英文副本名装简体中文
Function getInstanceName(strName)
	getInstanceName=Trim(strName)
	For i = 0 To UBound(Instance)
		If Trim(strName) = Instance(i)(0) Then
			getInstanceName = Instance(i)(1)
			Exit For
		End If
	Next
End Function

Function checkShowInstance(strName)
	If InStr(ShowInstance,strName) <> 0 Then
		checkShowInstance = true
	Else
		checkShowInstance = false
	End If
End Function

'盗贼 -> 潜行者
Function getHeXieProfessionName(strName)
	If strName = "盗贼" And langcode=0 Then
		getHeXieProfessionName = "潜行者"
	Else
		getHeXieProfessionName = strName
	End If
End Function


'操作完成提示信息条
Sub getCueInfo(strtxt)
	Response.write "<table class='cuebarframe'><tr><td><img src='style/images/cue_left.gif' /></td><td class='cue_info'>"&strtxt&"</td><td><img src='style/images/cue_right.gif' /></td></tr></table>"
End Sub

'获取事件相应图标
Function getEventIco(strEventClass)
	Dim arrEvents(7) , strIcoPatch , strPicFlieName
	Select Case strEventClass
	Case "加入"
		strPicFlieName = ""
	Case "离开"
		strPicFlieName = ""
	Case "拾取"
		strPicFlieName = "event1.gif"
	Case "分解"
		strPicFlieName = "event2.gif"
	Case "仓库"
		strPicFlieName = "event2.gif"
	Case "击杀"
		strPicFlieName = "event5.gif"
	Case "首次击杀"
		strPicFlieName = "event5.gif"
	Case "团队事件"
		strPicFlieName = "event6.gif"
	Case "个人事件"
		strPicFlieName = "event7.gif"
	Case "活动事件"
		strPicFlieName = "event6.gif"
	End Select
	getEventIco = "<img src='"&StylePath&"/images/"&strPicFlieName&"' class='eventico' />"
	If strPicFlieName = "" Then getEventIco= ""
End Function 

'识别双字节的字符省略函数
Function len2(str)
	dim l,tj,casc,izj
	l=len(str)
	tj=0
	for izj=1 to l
	casc=Abs(Ascw(Mid(str,izj,1)))
	if casc>255 Then tj=tj+1
	tj=tj+1
	Next
	len2=tj
End Function

'获得库中指定职业的现有数量
Function getClassMemberCount(strClassName)
	If strClassName = "" Then
		sql= "select COUNT(*) from player"
	Else
		sql = "select COUNT(*) from player where player_profession='"&strClassName&"'"
	End If
	rs2.open sql,conn,1,1
	getClassMemberCount = rs2(0)
	rs2.close
End Function




Function getStandardDate($datestr) {
	
}
%>